import os 
import sys 
import time 
import curses




class CliWindow:
    def __init__(self):
        self.stdscr = curses.initscr()
        self.curs_disnable()
        pass 

    def __del__(self):
        self.curs_enable()
        self.stdscr = None 


    def curs_enable(self):
        curses.curs_set(1)

    def curs_disnable(self):
        curses.curs_set(0)

    def refresh(self, lines, *args, **kws):
        self.stdscr.clear() 
        for i, line in enumerate(lines):
            self.stdscr.addstr(i, 0, line)  # 在指定位置添加文本
        self.stdscr.refresh()  # 刷新屏幕



if __name__ == "__main__":
    import time 
    cliw = CliWindow()
    for i in range(100):
        cliw.refresh([f"i: {i: 05}"])
        time.sleep(1)
    
    

